<?php
session_start();
$arr=array_merge(range(0,9),range('a','z'),range('A','Z'));
shuffle($arr);
$str=join(' ',array_slice($arr,0,4));
$string = strtolower($str);
$_SESSION['code']=str_replace(" ",'',$string);
// var_dump($_SESSION['code']);
 $img = imagecreatetruecolor(150,50);
 $black=imagecolorallocate($img,0,0,0);
 $white=imagecolorallocate($img,255,255,255);
 imagefill($img,0,0,$white);
 imagettftext($img,30,5,10,45,$black,'d.ttf',$str);
 for($i=0;$i<5;$i++){
     imagearc($img,mt_rand(0,150),mt_rand(0,50),mt_rand(0,150),mt_rand(0,50),mt_rand(0,360),mt_rand(0,360),$black);
 }
 header('content-type:image/png');
 imagepng($img);
 imagedestroy($img);

// ?>